package openbang.account.web.portal.client;

import java.util.List;

import openbang.account.service.intf.AccountService;
import openbang.account.service.vo.UserLoginInfo;
import openbang.account.web.portal.widget.ViewSessionList;

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.RootPanel;

/**
 * 
 * 显示在线人员信息，包括未登录的。
 * （1）这是 web icq 的基础。
 * 
 * @author aibozeng
 *
 */

public class ListSession implements EntryPoint {
	final ViewSessionList viewUserList = new ViewSessionList();
	
	@Override
	public void onModuleLoad() {		
		RootPanel.get("listsession_div").add(viewUserList);
		AccountService.Util.getInstance().getAllSessionUser(new AsyncCallback<List<UserLoginInfo>>(){
			public void onFailure(Throwable caught) {
				//隐藏进度条
				RootPanel.get("loading").setVisible(false);
				Window.alert(caught.getMessage());
			}
			public void onSuccess(List<UserLoginInfo> result) {
				//隐藏进度条
				RootPanel.get("loading").setVisible(false);
				if(result==null){
					Window.alert("没有在线信息");
					return;
				}
				viewUserList.initData(result);
			}
		});
	}
	
}
